﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kurogane.Compiler {
	/// <summary>
	/// 字句解析して，切り出したもの
	/// </summary>
	public abstract class Token {
		public abstract string Value { get; }

		public override string ToString() {
			return this.GetType().Name + " : " + Value;
		}
	}

	/// <summary>
	/// SymbolやLiteralなど、名詞として対象となりえるトークン
	/// </summary>
	public abstract class TargetToken : Token{

	}

	/// <summary>
	/// 変数名やクラス名，関数名などを示すトークン
	/// </summary>
	public class SymbolToken : TargetToken {
		private readonly string _value;

		public SymbolToken(string value) {
			_value = value;
		}

		public override string Value { get { return _value; } }
	}

	/// <summary>
	/// 文字列リテラルを示すトークン
	/// </summary>
	public class LiteralToken : TargetToken {
		private readonly string _value;

		public LiteralToken(string value) {
			_value = value;
		}

		public override string Value { get { return _value; } }
	}

	/// <summary>
	/// 数値リテラルを示すトークン
	/// </summary>
	public abstract class NumberToken : TargetToken { }

	/// <summary>
	/// 整数リテラルを示すトークン
	/// </summary>
	public class IntegerToken : NumberToken {
		private readonly int _value;

		public IntegerToken(int value) {
			_value = value;
		}

		public override string Value { get { return _value.ToString(); } }
		public int IntValue { get { return _value; } }
	}

	/// <summary>
	/// 小数リテラルを示すトークン
	/// </summary>
	public class DecimalToken : NumberToken {
		private readonly double _value;

		public DecimalToken(double value) {
			_value = value;
		}

		public override string Value { get { return _value.ToString(); } }
		public double DecimalValue { get { return _value; } }
	}

	/// <summary>
	/// 助詞を示すトークン
	/// </summary>
	public class PostPositionToken : Token {
		private readonly string _value;

		public PostPositionToken(string value) {
			_value = value;
		}

		public override string Value { get { return _value; } }

	}

	/// <summary>
	/// 演算子を示すトークン
	/// </summary>
	public class OperatorToken : Token {
		private readonly string _value;

		public OperatorToken(string value) {
			_value = value;
		}

		public override string Value { get { return _value; } }
	}

	/// <summary>
	/// 予約語を示すトークン
	/// </summary>
	public class ReservedToken : Token {
		private readonly string _value;

		public ReservedToken(string value) {
			_value = value;
		}

		public override string Value { get { return _value; } }
	}

	/// <summary>
	/// 句読点を示すトークン
	/// </summary>
	public class PunctuationToken : Token {
		private readonly string _value;

		public PunctuationToken(string value) {
			_value = value;
		}

		public override string Value { get { return _value; } }
	}

	/// <summary>
	/// 開き括弧を示すトークン
	/// </summary>
	public class OpenParenthesisToken : Token {
		public const char Char = '(';

		public override string Value { get { return "("; } }
	}

	/// <summary>
	/// 閉じ括弧を示すトークン
	/// </summary>
	public class CloseParenthesisToken : Token {
		public const char Char = ')';

		public override string Value { get { return ")"; } }
	}


}
